package com.inossem.warehousestorage_inossem.adapter.outStorage;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;

import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.activity.out_storage.OutStorageProductionListActivity;

/**
 * Created by leij on 2017/6/6.
 */

public class ProductionOutStorageListAdapter extends BaseAdapter {

    private Context mContext;
    private LayoutInflater inflater;
    private OutStorageProductionListActivity.OutStoragePickingListener mOutStorageProductionListener;
    private String mCondition;

    public ProductionOutStorageListAdapter(Context context, String condition, OutStorageProductionListActivity.OutStoragePickingListener outStorageProductionListener) {
        mContext = context;
        mOutStorageProductionListener = outStorageProductionListener;
        inflater = LayoutInflater.from(context);
        mCondition = condition;
    }

    @Override
    public int getCount() {
        return 1;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (position == 0) {
            convertView = inflater.inflate(R.layout.view_out_storage_picking_list_first_item, null);
            EditText condition = (EditText) convertView.findViewById(R.id.condition);
            ImageView search = (ImageView) convertView.findViewById(R.id.search);
            condition.setText(mCondition);
            condition.setHint("请输入生产预留单号");
            search.setOnClickListener(mOutStorageProductionListener.getNoDoubleClickListener(condition));
        }
//        else {
//            OutStoragePickingListBean.BodyBean pickingOutInstorageItem = mPickingOutStorageList.get(position - 1);
//            ViewHolder viewHolder;
//            if (convertView == null || (convertView != null && convertView.getTag() == null)) {
//                convertView = inflater.inflate(R.layout.view_out_storage_picking_list, null);
//                viewHolder = new ViewHolder();
//                //初始化控件
//                initView(viewHolder, convertView);
//                convertView.setTag(viewHolder);
//            } else {
//                viewHolder = (ViewHolder) convertView.getTag();
//            }
//            //初始化数据
//            initData(mContext, viewHolder, convertView, pickingOutInstorageItem);
//        }
        return convertView;
    }

//    private void initView(ViewHolder viewHolder, View view) {
//        viewHolder.pickingOutStorageNumber = (TextView) view.findViewById(R.id.pickingOutStorageNumber);
//        viewHolder.pickingOutStorageId = (TextView) view.findViewById(R.id.pickingOutStorageId);
//        viewHolder.department = (TextView) view.findViewById(R.id.department);
//        viewHolder.applicant = (TextView) view.findViewById(R.id.applicant);
//        viewHolder.createTime = (TextView) view.findViewById(R.id.createTime);
//    }
//
//    private void initData(Context context, ViewHolder viewHolder, View view, OutStoragePickingListBean.BodyBean pickingOutStorageItem) {
//        viewHolder.pickingOutStorageNumber.setText(pickingOutStorageItem.getRefer_receipt_code());
//        viewHolder.pickingOutStorageId.setText(pickingOutStorageItem.getRefer_receipt_id());
//        viewHolder.department.setText(pickingOutStorageItem.getApply_depart_name());
//        viewHolder.applicant.setText(pickingOutStorageItem.getApply_user_name());
//        viewHolder.createTime.setText(pickingOutStorageItem.getApply_time());
//        view.setOnClickListener(new NoDoubleClickListener() {
//            @Override
//            public void onNoDoubleClick(View v) {
//                Intent intent = new Intent(context, OutStoragePickingOverviewActivity.class);
//                intent.putExtra(OutStorageExtra.OUT_STORAGE_PICKING_NUMBER, viewHolder.pickingOutStorageId.getText().toString());
//                context.startActivity(intent);
//            }
//        });
//    }
//
//    private class ViewHolder {
//        private TextView pickingOutStorageNumber, pickingOutStorageId, department, applicant, createTime;
//    }
}
